<template>
  <div>
    <Button size="large" type="text" @click="backHome">返回首页</Button>
    <Button size="large" type="text" @click="backPrev">返回上一页({{ second }}s)</Button>
  </div>
</template>

<script>
import '../error.scss'

export default {
  name: 'BackBtnGroup',
  data() {
    return {
      second: 10,
      timer: null
    }
  },
  mounted() {
    this.timer = setInterval(() => {
      this.second === 0 ? this.backPrev() : this.second--
    }, 1000)
  },
  beforeDestroy() {
    clearInterval(this.timer)
  },
  methods: {
    backHome() {
      this.$router.replace({
        name: this.config.HOME_NAME
      })
    },
    backPrev() {
      this.$router.go(-1)
    }
  }
}
</script>
